package com.example.flowerpcback.controller;

import com.example.flowerpcback.dto.Enterprise;
import com.example.flowerpcback.dto.Roles;
import com.example.flowerpcback.req.EnterpriseReq;
import com.example.flowerpcback.req.RolesReq;
import com.example.flowerpcback.resp.CommonResp;
import com.example.flowerpcback.resp.EnterpriseResp;
import com.example.flowerpcback.resp.PageResp;
import com.example.flowerpcback.resp.RolesResp;
import com.example.flowerpcback.services.EnterpriseService;
import com.example.flowerpcback.services.RoleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;


@RestController //这是返回接口
@RequestMapping("/enterprise")
public class EnterpriseController {

    private static final Logger LOG = LoggerFactory.getLogger(EnterpriseController.class);

    @Resource
    private EnterpriseService enterpriseService;


    @PostMapping("/save")
    public CommonResp<Roles> save(@Valid @RequestBody EnterpriseReq req){
        CommonResp resp= new CommonResp<>();
        Enterprise res = enterpriseService.save(req);
        resp.setData(res);
        return  resp;
    }

    @GetMapping("/list")
    public CommonResp<PageResp<EnterpriseResp>> list(@Valid EnterpriseReq req){
        CommonResp<PageResp<EnterpriseResp>> resp= new CommonResp<>();
        PageResp<EnterpriseResp> res = enterpriseService.list(req);
        resp.setData(res);
        return  resp;
    }

    @GetMapping("/delete")
    public CommonResp delete(@Valid EnterpriseReq req){
        CommonResp resp= new CommonResp<>();
        enterpriseService.delete(req);
        return  resp;
    }

}

